#!/usr/bin/env python

import sys
from climax import CliParser

status_config_maker = (CliParser("""aliases: st

show changed files in the working directory

    Show status of files in the repository. If names are given, only files
    that match are shown. Files that are clean or ignored or the source of a
    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
    -C/--copies or -A/--all are given. Unless options described with "show
    only ..." are given, the options -mardu are used.

    Option -q/--quiet hides untracked (unknown and ignored) files unless
    explicitly requested with -u/--unknown or -i/--ignored.

    Note:
       status may appear to disagree with diff if permissions have changed or
       a merge has occurred. The standard diff format does not report
       permission changes and diff only reports changes relative to one merge
       parent.

    If one revision is given, it is used as the base revision. If two
    revisions are given, the differences between them are shown. The --change
    option can also be used as a shortcut to list the changed files of a
    revision from its first parent.

    The codes used to show the status of files are:

      M = modified
      A = added
      R = removed
      C = clean
      ! = missing (deleted by non-hg command, but still tracked)
      ? = not tracked
      I = ignored
        = origin of the previous file listed as A (added)

    Examples:

    - show changes in the working directory relative to a changeset:

        hg status --rev 9353

    - show all changes including copies in an existing changeset:

        hg status --copies --change 9353

    - get a NUL separated list of added files, suitable for xargs:

        hg status -an0

    Returns 0 on success.
""")
    .Take('-A').Aka('--all').As(bool).Will('show status of all files')
    .Take('-m').Aka('--modified').As(bool).Will('show only modified files')
    .Take('-a').Aka('--added').As(bool).Will('show only added files')
    .Take('-r').Aka('--removed').As(bool).Will('show only removed files')
    .Take('-d').Aka('--deleted').As(bool).Will('show only deleted (but tracked) files')
    .Take('-c').Aka('--clean').As(bool).Will('show only files without changes')
    .Take('-u').Aka('--unknown').As(bool).Will('show only unknown (not tracked) files')
    .Take('-i').Aka('--ignored').As(bool).Will('show only ignored files')
    .Take('-n').Aka('--no-status').As(bool).Will('hide status prefix')
    .Take('-C').Aka('--copies').As(bool).Will('show source of copied files')
    .Take('-0').Aka('--print0-status').As(bool).Will('end filenames with NUL, for use with xargs')
    .Take('--rev').As(str).For('REV').Will('show difference from revision')  # [+] ???
    .Take('--change').As(str).For('REV').Will('list the changed files of a revision')  # [+] ???
    .Take('-I').Aka('--include').As(str).For('PATTERN').Will('include names matching the given patterns')  # [+] ???
    .Take('-X').Aka('--exclude').As(str).For('PATTERN').Will('exclude names matching the given patterns')
    .Take('-S').Aka('--subrepos').As(bool).Will('recurse into subrepositories')
    )

log_config_maker = (CliParser("""
aliases: history

show revision history of entire repository or files

    Print the revision history of the specified files or the entire project.

    If no revision range is specified, the default is "tip:0" unless --follow
    is set, in which case the working directory parent is used as the starting
    revision.

    File history is shown without following rename or copy history of files.
    Use -f/--follow with a filename to follow history across renames and
    copies. --follow without a filename will only show ancestors or
    descendants of the starting revision.

    By default this command prints revision number and changeset id, tags,
    non-trivial parents, user, date and time, and a summary for each commit.
    When the -v/--verbose switch is used, the list of changed files and full
    commit message are shown.

    Note:
       log -p/--patch may generate unexpected diff output for merge
       changesets, as it will only compare the merge changeset against its
       first parent. Also, only files different from BOTH parents will appear
       in files:.

    Note:
       for performance reasons, log FILE may omit duplicate changes made on
       branches and will not show deletions. To see all changes including
       duplicates and deletions, use the --removed switch.

    Some examples:

    - changesets with full descriptions and file lists:

        hg log -v

    - changesets ancestral to the working directory:

        hg log -f

    - last 10 commits on the current branch:

        hg log -l 10 -b .

    - changesets showing all modifications of a file, including removals:

        hg log --removed file.c

    - all changesets that touch a directory, with diffs, excluding merges:

        hg log -Mp lib/

    - all revision numbers that match a keyword:

        hg log -k bug --template "{rev}\n"

    - check if a given changeset is included is a tagged release:

        hg log -r "a21ccf and ancestor(1.9)"

    - find all changesets by some user in a date range:

        hg log -k alice -d "may 2008 to jul 2008"

    - summary of all changesets after the last tag:

        hg log -r "last(tagged())::" --template "{desc|firstline}\n"

    See "hg help dates" for a list of formats valid for -d/--date.

    See "hg help revisions" and "hg help revsets" for more about specifying
    revisions.

    Returns 0 on success.""")
    .Take('-f').Aka('--follow').As(bool).Will('follow changeset history, or file history across copies and renames')
    .Take('--follow-first').As(bool).Will('only follow the first parent of merge changesets (DEPRECATED)')
    .Take('-d').Aka('--date').Named('DATE').As(str).Will('show revisions matching date spec')
    .Take('-C').Aka('--copies').As(bool).Will('show copied files')
    .Take('-k').Aka('--keyword').Named('TEXT').As(str).Will('do case-insensitive search for a given text')
    .Take('-r').Aka('--rev').Named('REV').As(str).Will('show the specified revision or range')
    .Take('--removed').As(bool).Will('include revisions where files were removed')
    .Take('-m').Aka('--only-merges').As(bool).Will('show only merges (DEPRECATED)')
    .Take('-u').Aka('--user').Named('USER').As(str).Will('revisions committed by user')
    .Take('--only-branch').Named('BRANCH').As(str).Will('show only changesets within the given named branch (DEPRECATED)')
    .Take('-b').Aka('--branch').Named('BRANCH').As(str).Will('show changesets within the given named branch')
    .Take('-P').Aka('--prune').Named('REV').As(str).Will('do not display revision or any of its ancestors')
    .Take('--hidden').As(bool).Will('show hidden changesets (DEPRECATED)')
    .Take('-p').Aka('--patch').As(bool).Will('show patch')
    .Take('-g').Aka('--git').As(bool).Will('use git extended diff format')
    .Take('-l').Aka('--limit').Named('NUM').As(int).Will('limit number of changes displayed')
    .Take('-M').Aka('--no-merges').As(bool).Will('do not show merges')
    .Take('--stat').As(bool).Will('output diffstat-style summary of changes')
    .Take('--style').Named('STYLE').As(str).Will('display using template map file')
    .Take('--template').Named('TEMPLATE').As(str).Will('display with template')
    .Take('-I').Aka('-include').Named('PATTERN').As(str).Will('include names matching the given patterns')
    .Take('-X').Aka('--exclude').Named('PATTERN').As(str).Will('exclude names matching the given patterns')
    )

main_maker = (CliParser()
    .Take('status').Command(status_config_maker).Will('show changed files in the working directory')
    .Take('log').Command(log_config_maker).Will('show revision history of entire repository or files')
    )


main_maker.Parse(sys.argv)
#print main_maker.GetHelpMessage()
